package gui.panels;

import gui.TransEsc;

import java.awt.Color;
import java.awt.Rectangle;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JLabel;
import javax.swing.JSeparator;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import java.awt.Font;

public class PanelMain extends JPanel{
	
	private JFrame mainFrame;
	Rectangle panelDiscriminacaoBounds = new Rectangle(1250, 500);
	Rectangle panelRegistroIndiretoBounds = new Rectangle(1250, 500);
	Rectangle panelRegistroDiretoBounds = new Rectangle(1250, 500);
	Rectangle panelControleMensalBounds = new Rectangle(1250, 500);
	
	public PanelMain(final TransEsc transEsc) {
		setToolTipText("");
		setBackground(Color.LIGHT_GRAY);
		setLayout(null);
		
		JButton btnNewButton = new JButton("Cadastrar");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
				mainFrame.getContentPane().removeAll();
				mainFrame.getContentPane().add(new PanelDiscriminacao(transEsc,panelDiscriminacaoBounds,mainFrame));
				mainFrame.revalidate();
				mainFrame.repaint();
				transEsc.setBounds((int)panelDiscriminacaoBounds.getWidth(),(int)panelDiscriminacaoBounds.getHeight());
				
			}
		});
		btnNewButton.setBounds(380, 94, 106, 23);
		add(btnNewButton);
		
		JButton btnNewButton_1 = new JButton("Cadastrar");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
				mainFrame.getContentPane().removeAll();
				mainFrame.getContentPane().add(new PanelRegistroIndireto(transEsc,panelRegistroIndiretoBounds,mainFrame));
				mainFrame.revalidate();
				mainFrame.repaint();
				transEsc.setBounds((int)panelRegistroIndiretoBounds.getWidth(),(int)panelRegistroIndiretoBounds.getHeight());
				
			}
		});
		btnNewButton_1.setBounds(380, 141, 106, 23);
		add(btnNewButton_1);
		
		JButton btnNewButton_2 = new JButton("Cadastrar");
		btnNewButton_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				mainFrame.getContentPane().removeAll();
				mainFrame.getContentPane().add(new PanelRegistroDireto(transEsc,panelRegistroDiretoBounds,mainFrame));
				mainFrame.revalidate();
				mainFrame.repaint();
				transEsc.setBounds((int)panelRegistroDiretoBounds.getWidth(),(int)panelRegistroDiretoBounds.getHeight());
				
			}
		});
		btnNewButton_2.setBounds(380, 188, 106, 23);
		add(btnNewButton_2);
		
		JButton btnNewButton_3 = new JButton("Cadastrar");
		btnNewButton_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				mainFrame.getContentPane().removeAll();
				mainFrame.getContentPane().add(new PanelControleMensal(transEsc,panelRegistroDiretoBounds,mainFrame));
				mainFrame.revalidate();
				mainFrame.repaint();
				transEsc.setBounds((int)panelControleMensalBounds.getWidth(),(int)panelControleMensalBounds.getHeight());
			}
		});
		btnNewButton_3.setBounds(380, 235, 106, 23);
		add(btnNewButton_3);
		
		JButton btnNewButton_4 = new JButton("Cadastrar");
		btnNewButton_4.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				mainFrame.getContentPane().removeAll();
				mainFrame.getContentPane().add(new PanelControleViagens(transEsc,panelRegistroDiretoBounds,mainFrame));
				mainFrame.revalidate();
				mainFrame.repaint();
				transEsc.setBounds((int)panelControleMensalBounds.getWidth(),(int)panelControleMensalBounds.getHeight());
			
			}
		});
		btnNewButton_4.setBounds(380, 277, 106, 23);
		add(btnNewButton_4);
		
		JLabel lblDiscriminaoDeRotas = new JLabel("Discrimina\u00E7\u00E3o de Rotas");
		lblDiscriminaoDeRotas.setBounds(25, 98, 230, 14);
		add(lblDiscriminaoDeRotas);
		
		JLabel lblFichaRegistroDe = new JLabel("Ficha Registro de Transporte Escolar - Forma Indireta");
		lblFichaRegistroDe.setBounds(25, 145, 360, 14);
		add(lblFichaRegistroDe);
		
		JLabel lblFichaRegistroDe_1 = new JLabel("Ficha Registro de Transporte Escolar - Forma Direta");
		lblFichaRegistroDe_1.setBounds(25, 192, 349, 14);
		add(lblFichaRegistroDe_1);
		
		JLabel lblFichaDeControle = new JLabel("Ficha de Controle Mensal de Execu\u00E7\u00E3o do Transporte Escolar");
		lblFichaDeControle.setBounds(25, 239, 360, 14);
		add(lblFichaDeControle);
		
		JLabel lblControleDasViagens = new JLabel("Controle das Viagens - Hor\u00E1rios e Alunos Transportados");
		lblControleDasViagens.setBounds(25, 281, 360, 14);
		add(lblControleDasViagens);
		
		JButton btnBuscaralterar = new JButton("Buscar/Alterar");
		btnBuscaralterar.setBounds(496, 94, 127, 23);
		add(btnBuscaralterar);
		
		JButton button = new JButton("Buscar/Alterar");
		button.setBounds(496, 141, 127, 23);
		add(button);
		
		JButton button_1 = new JButton("Buscar/Alterar");
		button_1.setBounds(496, 188, 127, 23);
		add(button_1);
		
		JButton button_2 = new JButton("Buscar/Alterar");
		button_2.setBounds(496, 235, 127, 23);
		add(button_2);
		
		JSeparator separator = new JSeparator();
		separator.setBounds(25, 128, 598, 2);
		add(separator);
		
		JSeparator separator_1 = new JSeparator();
		separator_1.setBounds(25, 175, 598, 2);
		add(separator_1);
		
		JSeparator separator_2 = new JSeparator();
		separator_2.setBounds(25, 222, 598, 2);
		add(separator_2);
		
		JSeparator separator_3 = new JSeparator();
		separator_3.setBounds(25, 264, 598, 2);
		add(separator_3);
		
		JButton button_3 = new JButton("Buscar/Alterar");
		button_3.setBounds(496, 277, 127, 23);
		add(button_3);
		
		JPanel panel = new JPanel();
		panel.setBackground(Color.LIGHT_GRAY);
		panel.setBounds(25, 10, 614, 56);
		add(panel);
		
		JLabel lblSistemaDeTransporte = new JLabel("Sistema de Transporte Escolar Municipal");
		lblSistemaDeTransporte.setFont(lblSistemaDeTransporte.getFont().deriveFont(lblSistemaDeTransporte.getFont().getStyle() | Font.BOLD | Font.ITALIC, lblSistemaDeTransporte.getFont().getSize() + 14f));
		GroupLayout gl_panel = new GroupLayout(panel);
		gl_panel.setHorizontalGroup(
			gl_panel.createParallelGroup(Alignment.LEADING)
				.addGroup(Alignment.TRAILING, gl_panel.createSequentialGroup()
					.addGap(54)
					.addComponent(lblSistemaDeTransporte, GroupLayout.DEFAULT_SIZE, 523, Short.MAX_VALUE)
					.addGap(37))
		);
		gl_panel.setVerticalGroup(
			gl_panel.createParallelGroup(Alignment.LEADING)
				.addGroup(Alignment.TRAILING, gl_panel.createSequentialGroup()
					.addGap(10)
					.addComponent(lblSistemaDeTransporte, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
					.addContainerGap())
		);
		panel.setLayout(gl_panel);
		
		
	}
	
	public void setMainFrame(JFrame frame){
		this.mainFrame = frame;
	}
}
